package com.ruoyi.web.controller.books;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.books.domain.BooksPerformanceForm;
import com.ruoyi.books.service.IBooksPerformanceFormService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 非遗演形式汇总Controller
 *
 * @author ruoyi
 * @date 2024-03-30
 */
@Anonymous
@RestController
@RequestMapping("/books/form")
public class BooksPerformanceFormController extends BaseController
{
    @Autowired
    private IBooksPerformanceFormService booksPerformanceFormService;

    /**
     * 查询非遗演形式汇总列表
     */
//    @PreAuthorize("@ss.hasPermi('bppks:form:list')")
    @GetMapping("/list")
    public TableDataInfo list(BooksPerformanceForm booksPerformanceForm)
    {
        startPage();
        List<BooksPerformanceForm> list = booksPerformanceFormService.selectBooksPerformanceFormList(booksPerformanceForm);
        return getDataTable(list);
    }

    /**
     * 导出非遗演形式汇总列表
     */
//    @PreAuthorize("@ss.hasPermi('bppks:form:export')")
    @Log(title = "非遗演形式汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BooksPerformanceForm booksPerformanceForm)
    {
        List<BooksPerformanceForm> list = booksPerformanceFormService.selectBooksPerformanceFormList(booksPerformanceForm);
        ExcelUtil<BooksPerformanceForm> util = new ExcelUtil<BooksPerformanceForm>(BooksPerformanceForm.class);
        util.exportExcel(response, list, "非遗演形式汇总数据");
    }

    /**
     * 获取非遗演形式汇总详细信息
     */
//    @PreAuthorize("@ss.hasPermi('bppks:form:query')")
    @GetMapping(value = "/{performanceFormId}")
    public AjaxResult getInfo(@PathVariable("performanceFormId") Long performanceFormId)
    {
        return success(booksPerformanceFormService.selectBooksPerformanceFormByPerformanceFormId(performanceFormId));
    }

    /**
     * 新增非遗演形式汇总
     */
//    @PreAuthorize("@ss.hasPermi('bppks:form:add')")
    @Log(title = "非遗演形式汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BooksPerformanceForm booksPerformanceForm)
    {
        return toAjax(booksPerformanceFormService.insertBooksPerformanceForm(booksPerformanceForm));
    }

    /**
     * 修改非遗演形式汇总
     */
//    @PreAuthorize("@ss.hasPermi('bppks:form:edit')")
    @Log(title = "非遗演形式汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BooksPerformanceForm booksPerformanceForm)
    {
        return toAjax(booksPerformanceFormService.updateBooksPerformanceForm(booksPerformanceForm));
    }

    /**
     * 删除非遗演形式汇总
     */
//    @PreAuthorize("@ss.hasPermi('bppks:form:remove')")
    @Log(title = "非遗演形式汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{performanceFormIds}")
    public AjaxResult remove(@PathVariable Long[] performanceFormIds)
    {
        return toAjax(booksPerformanceFormService.deleteBooksPerformanceFormByPerformanceFormIds(performanceFormIds));
    }
}
